<?php
/* @var $this ActivityDetailController */
/* @var $model ActivityDetail */

$this->breadcrumbs=array(
	'[活动明细]管理'=>array('admin'),
	'添加[活动明细]',
);
//设置页面标题
$this->pageTitle=Yii::app()->name.' - 添加[活动明细]';
$this->contentTitle='添加[活动明细]';
?>
<!--表单内容-->
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'activity-detail-form',
	'enableAjaxValidation'=>false,
        'clientOptions'=>array(
            'validateOnSubmit'=>true
        ),
    'htmlOptions'=>array('class'=>'ajax_form'),
)); ?>
    <link type="text/css" href="<?php echo Yii::app()->baseUrl?>/css/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
    <link type="text/css" href="<?php echo Yii::app()->baseUrl?>/css/jquery-ui-timepicker-addon.css" rel="stylesheet" />
    <script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/js/jquery-ui-1.8.17.custom.min.js"></script>
    <script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/js/jquery-ui-timepicker-addon.js"></script>
    <script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/js/jquery-ui-timepicker-zh-CN.js"></script>
<table cellspacing="1" class="myform">
	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'is_float'); ?></td>
 		<td>
			<?php echo $form->dropDownList($modelA,'is_float',array('1'=>'开馆','0'=>'闭馆','2'=>'团体','3'=>'报名已满'),
                                array('style'=>'float: left;')); ?> 
			<div class="errorMessage" id="ActivityDetail_is_float_em_" ></div>	
		</td>  
                
	</tr>

	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'activity_id'); ?></td>
		<td>
			 <?php echo $form->dropDownList($modelA,'activity_id',CHtml::listData(Activity::model()->findAll(), 'id', 'title'),
                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
			<div class="errorMessage" id="ActivityDetail_activity_id_em_" ></div>	
		</td>
	</tr>

	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'crowd_id'); ?></td>
		<td>
			<?php echo $form->dropDownList($modelA,'crowd_id',CHtml::listData(Crowd::model()->findAll(), 'id', 'title'),
                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
                    <div class="errorMessage" id="ActivityDetail_crowd_id_em_" ></div>	
		</td>
	</tr>

	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'remark'); ?></td>
		<td>
			<?php echo $form->textArea($modelA,'remark',array('rows'=>6, 'cols'=>50,'class'=>'fl input')); ?>
			<div class="errorMessage" id="ActivityDetail_remark_em_" ></div>	
		</td>
	</tr>
        
        
         <tr>
		<td align="right"><?php echo $form->labelEx($modelA,'begins'); ?></td>
		<td>
                        <input value="<?php echo $date.' 00:00:00' ; ?>" class="fl input" style="width:150px;" id="ActivityDetail_begins" name="ActivityDetail[begins]" type="text">
                       <div class="errorMessage" id="ActivityDetail_begins_em_" ></div>	
		</td>
	</tr>

	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'start'); ?></td>
		<td>
                        <input value="<?php echo $date.' 00:00:00' ; ?>" class="fl input" style="width:150px;" id="ActivityDetail_start" name="ActivityDetail[start]" type="text">
                       <div class="errorMessage" id="ActivityDetail_start_em_" ></div>	
		</td>
	</tr>
        
       

	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'end'); ?></td>
		<td>
                        <input class="fl input" style="width:150px;" id="ActivityDetail_end" name="ActivityDetail[end]" type="text"> 
                        <div class="errorMessage" id="ActivityDetail_end_em_" ></div>	
		</td>
	</tr>
        
	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'clander_start'); ?></td>
		<td>
                        <input class="fl input" style="width:150px;" id="ActivityDetail_clander_start" name="ActivityDetail[clander_start]" type="text">
                       <div class="errorMessage" id="ActivityDetail_clander_start_em_" ></div>	
		</td>
	</tr>        

        <tr>
		<td align="right"><?php echo $form->labelEx($modelA,'clander_end'); ?></td>
		<td>
                        <input class="fl input" style="width:150px;" id="ActivityDetail_clander_end" name="ActivityDetail[clander_end]" type="text">
                       <div class="errorMessage" id="ActivityDetail_clander_end_em_" ></div>	
		</td>
	</tr> 
        
	<tr>
		<td align="right"><?php echo $form->labelEx($modelA,'astrict'); ?></td>
		<td>
			<?php echo $form->textField($modelA,'astrict',array('class'=>'fl input')); ?>
                        <div class="errorMessage" id="ActivityDetail_astrict_em_" ></div>
		</td>
	</tr>

        <tr style="display: none;">
		<td align="right"><?php echo $form->labelEx($modelA,'is_state'); ?></td>
		<td>
			<?php echo $form->textField($modelA,'is_state',array('class'=>'fl input','value'=>'0')); ?>
                        <div class="errorMessage" id="ActivityDetail_is_state_em_" ></div>
		</td>
	</tr>
	<tr>
		<td align="right">线路安排</td>
		<td>
                    <div>
                        <div  style="margin-left:25em;" ><image  onclick="addList()" style="width:1.5em;"src=" <?php echo Yii::app()->baseUrl?>/images/u44.png" /> 
                            <span>添加</span>
                            </div>    
                        <div>
                            <table style="background: #F0F0F0;" >
                                <tr style="background: #F0F0F0;">
                                    <td></td>
                                    <td align="right"><image style="width:1.5em; margin-left: 15em; visibility: hidden;"src=" <?php echo Yii::app()->baseUrl?>/images/del.png" /></td>
                                </tr>
                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'car_id'); ?></td>
                                        <td>
                                            <?php echo $form->dropDownList($modelB,'car_id[]',CHtml::listData(Carinfo::model()->findAll(), 'id', 'code'),
                                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
                                            <?php echo $form->error($modelB,'car_id'); ?>
                                        </td>
                                </tr>

                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'go_time'); ?></td>
                                <td>
                                        <?php echo $form->textField($modelB,'go_time[]',array('size'=>15,'maxlength'=>255,'class'=>'fl input')); ?>
                                        <?php echo $form->error($modelB,'go_time'); ?>
                                </td>
                                </tr>

                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'position_id'); ?></td>
                                        <td>
                                            <?php echo $form->dropDownList($modelB,'position_id[]',CHtml::listData(Position::model()->findAll(), 'id', 'address'),
                                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
                                            <?php echo $form->error($modelB,'position_id'); ?>
                                        </td>
                                </tr>

                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'staff'); ?></td>
                                        <td>
                                            <?php echo $form->dropDownList($modelB,'staff[]',CHtml::listData(Staff::model()->findAll(), 'id', 'username'),
                                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
                                            <?php echo $form->error($modelB,'staff'); ?>
                                        </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div id="ch_list"></div>
		</td>
	</tr>
        <tr>
            <td align="right"></td>
            <td><div class="errorMessage" id="Line_detail_em_" ></div></td>
        </tr>
	<tr>
        <td align="right"></td>
        <td>
            <!--<input class="but" type="submit" name="yt0" value="提 交" />-->  
                <?php
                       echo CHtml::ajaxSubmitButton('提交信息', CHtml::normalizeUrl(array('create')), array(
                           'type' => 'POST',
                           'data' => 'js:jQuery(this).parents("form").serialize()+"&isAjaxRequest=1"',
                           'success' =>
                           'function(data){
//                              alert(data);
                                if(data==1){
                                        location.href = "/ex/sign/index.php/activity/clander";                                   
                                }else{    
                                        var d_t=eval("("+data+")");
                                        clear_list();
                                        $.each(d_t,function(k,v){

                                              $("#"+k+"_em_").html("<span>"+v+"</span>");
                                        });  
                                    }
                                }'
                               ), array(
                            'id' => 'ajaxSubmit',
                            'name' => 'ajaxSubmit',
                            'class'=>'but'                           

                       ));
                       ?>            
        </td>
    </tr>
    
    
    
    <script>
        //日历控件
        $("#ActivityDetail_start").datetimepicker({
            //showOn: "button",
            //buttonImage: "/css/images/icon_calendar.gif",
            //buttonImageOnly: true,
            showSecond: true,
            dateFormat:'yy-mm-dd',
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        });    
        $("#ActivityDetail_end").datetimepicker({
            //showOn: "button",
            //buttonImage: "/css/images/icon_calendar.gif",
            //buttonImageOnly: true,
            showSecond: true,
            dateFormat:'yy-mm-dd',
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        });    
        $("#ActivityDetail_begins").datetimepicker({
            //showOn: "button",
            //buttonImage: "/css/images/icon_calendar.gif",
            //buttonImageOnly: true,
            showSecond: true,
            dateFormat:'yy-mm-dd',
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        });
        $("#ActivityDetail_clander_start").datetimepicker({
            //showOn: "button",
            //buttonImage: "/css/images/icon_calendar.gif",
            //buttonImageOnly: true,
            showSecond: true,
            dateFormat:'yy-mm-dd',
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        });          
        $("#ActivityDetail_clander_end").datetimepicker({
            //showOn: "button",
            //buttonImage: "/css/images/icon_calendar.gif",
            //buttonImageOnly: true,
            showSecond: true,
            dateFormat:'yy-mm-dd',
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        });         
//        $("#go_time").datetimepicker({
//            //showOn: "button",
//            //buttonImage: "/css/images/icon_calendar.gif",
//            //buttonImageOnly: true,
//            showSecond: true,
//            dateFormat:'yy-mm-dd',
//            timeFormat: 'hh:mm:ss',
//            stepHour: 1,
//            stepMinute: 1,
//            stepSecond: 1
//        });          
        var add_id=1;
        function addList(){
            var div= document.createElement("div"); 
            var temp = hereDoc(function () {/*
                           <table style="background: #F0F0F0; margin-top: 1em;" >
                                <tr style="background: #F0F0F0;">
                                    <td></td>
                                    <td align="right"><image onclick="clear_div(add_id)" style="width:1.5em; margin-left: 15em;"src=" <?php echo Yii::app()->baseUrl?>/images/del.png" /></td>
                                </tr>
                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'car_id'); ?></td>
                                        <td>
                                            <?php echo $form->dropDownList($modelB,'car_id[]',CHtml::listData(Carinfo::model()->findAll(), 'id', 'code'),
                                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
                                            <?php echo $form->error($modelB,'car_id'); ?>
                                        </td>
                                </tr>

                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'go_time'); ?></td>
                                <td>
                                        <?php echo $form->textField($modelB,'go_time[]',array('size'=>15,'maxlength'=>255,'class'=>'fl input')); ?>
                                        <?php echo $form->error($modelB,'go_time'); ?>
                                </td>
                                </tr>

                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'position_id'); ?></td>
                                        <td>
                                            <?php echo $form->dropDownList($modelB,'position_id[]',CHtml::listData(Position::model()->findAll(), 'id', 'address'),
                                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
                                            <?php echo $form->error($modelB,'position_id'); ?>
                                        </td>
                                </tr>

                                <tr style="background: #F0F0F0;">
                                        <td align="right"><?php echo $form->labelEx($modelB,'staff'); ?></td>
                                        <td>
                                            <?php echo $form->dropDownList($modelB,'staff[]',CHtml::listData(Staff::model()->findAll(), 'id', 'username'),
                                                array('empty'=>'-----请选择----','style'=>'float: left;')); ?> 
                                            <?php echo $form->error($modelB,'staff'); ?>
                                        </td>
                                </tr>
                            </table>
                    */});
//                    var new_id="clader_go_time"+add_id;
                    temp=temp.replace("add_id",add_id);
//                    temp=temp.replace("clader_go_time",new_id);
                    div.innerHTML=temp;
                    div.id='add_div'+add_id;
//                    div.style.background="#f4e7d4"; 
                    div.className="div_filter";
                    add_id+=1;
                    //document.getElementById("ch_list").innerHTML= temp;
                    document.getElementById("ch_list").appendChild(div);                       
                    
        }
        function clear_div(id){
                $("#add_div"+id).html("");
                $("#add_div"+id).remove();
        }
        function hereDoc(f) {　
            return f.toString().replace(/^[^\/]+\/\*!?\s?/, '').replace(/\*\/[^\/]+$/, '');
        }
        
         function clear_list(){
                    $("#ActivityDetail_activity_id_em_").html("");
                    $("#ActivityDetail_crowd_id_em_").html("");
                    $("#ActivityDetail_end_em_").html("");
                    $("#ActivityDetail_start_em_").html("");
                    $("#ActivityDetail_astrict_em_").html("");
                    $("#ActivityDetail_begins_em_").html("");
            }

    </script>
</table>  
<?php $this->endWidget(); ?>
<!--表单内容-->
